package cn.shopifymall.response;

import javax.servlet.ServletOutputStream;
import java.io.IOException;

/**
 * @Author 孤风雪影
 * @Email gitee.com/efairy520
 * @Date 2024/2/27 0:59
 * @Version 1.0
 */
public class ResponseServletOutputStream extends ServletOutputStream {

    private byte[] bytes = new byte[1024];
    private int pos = 0;

    /**
     * 此方法会被多次调用，一次写一个字节
     * @param b   the <code>byte</code>.
     * @throws IOException
     */
    @Override
    public void write(int b) throws IOException {
        bytes[pos] = (byte) b;
        pos++;
    }

    public byte[] getBytes() {
        return bytes;
    }

    public int getPos() {
        return pos;
    }
}
